<script>
import util from '@/common/util.js';
export default {
	globalData: {StatusBar:null,CustomBar:null,windowWidth:null,windowHeight:null}, 
	onLaunch: function() { 
		var that = this;
		//升级 
		//#ifdef APP-PLUS   
		/* 5+环境锁定屏幕方向 */
		plus.screen.lockOrientation('portrait-primary'); //锁定
		var server = util.baseUrl + '/api/app_update'; //检查更新地址
		var req = {
			//升级检测数据
			appid: plus.runtime.appid,
			version: plus.runtime.version.split('.').join(''),
			imei: plus.device.imei,
			platform: plus.os.name,
			source: 'UniappFast'  //APP来源，用于一个网站有多个APP时判断是那个APP
		}; //.split('.').join('')
		uni.request({
			url: server,
			data: req,
			success: res => {
				if (res.statusCode == 200 && res.data.status) {
					uni.showModal({
						//提醒用户更新
						title: '更新提示',
						content: res.data.data.msg,
						success: r => {
							if (r.confirm) {
								//应用市场更新
								plus.runtime.openURL(res.data.data.url);
								//plus.runtime.restart();
							}
						}
					});
				}
			},
			error: res => {
				/* uni.showModal({
					//提醒用户更新
					title: '检查更新失败7',
					content: req.appid		+" 版本 "	+reg.version
				});	 */
			}
		});
		//#endif
		// #ifdef MP-WEIXIN
		if (wx.canIUse('getUpdateManager')) {
			const updateManager = wx.getUpdateManager();
			updateManager.onCheckForUpdate(function(res) {
				// 请求完新版本信息的回调
				if (res.hasUpdate) {
					updateManager.onUpdateReady(function() {
						uni.showModal({
							//提醒用户更新
							title: '更新提示',
							content: '新版本已经上线啦~，为了获得更好的体验，建议立即更新',
							success: r => {
								if (r.confirm) {
									// 新的版本已经下载好，调用 applyUpdate 应用新版本并重启
									updateManager.applyUpdate();
								}
							}
						});
					});
					updateManager.onUpdateFailed(function() {
						// 新的版本下载失败
						util.msg('新版本更新失败，为了获得更好的体验，请您删除当前小程序，重新搜索打开');
					});
				}
			});
		}
		// #endif
		//话系统信息 比如导航栏高度
		uni.getSystemInfo({
			success: function(e) {
				// #ifndef MP
				that.globalData.StatusBar = e.statusBarHeight;
				if (e.platform == 'android') {
					that.globalData.CustomBar = e.statusBarHeight + 50;
				} else {
					that.globalData.CustomBar = e.statusBarHeight + 45;
				}
				// #endif

				// #ifdef MP-WEIXIN
				that.globalData.StatusBar = e.statusBarHeight;
				let custom = wx.getMenuButtonBoundingClientRect();
				that.globalData.Custom = custom;
				that.globalData.CustomBar = custom.bottom + custom.top - e.statusBarHeight;
				// #endif
 
				// #ifdef MP-ALIPAY
				that.globalData.StatusBar = e.statusBarHeight;
				that.globalData.CustomBar = e.statusBarHeight + e.titleBarHeight;
				// #endif
				that.globalData.windowWidth = e.windowWidth;
				that.globalData.windowHeight = e.windowHeight;
				/* plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {
						//console.log(JSON.stringify(wgtinfo));
						console.log(wgtinfo.version); //应用版本号
						that.$options.globalData.appVersion = wgtinfo.version;
					}) */
			}
		});
        
	},
	onShow: function() {},

	onHide: function() {}
};
</script>

<style lang="scss">
/*每个页面公共css */
@import 'colorui/main.css';
@import 'colorui/icon.css';
@import 'static/css/iconfont.css';
/*每个页面公共css */
page {
	min-height: 100%;
	background-color: #fafafa;
}

/* #ifdef MP-BAIDU */
page {
	width: 100%;
	height: 100%;
	display: block;
}

swan-template {
	width: 100%;
	min-height: 100%;
	display: flex;
}

/* 原生组件模式下需要注意组件外部样式 */
custom-component {
	width: 100%;
	min-height: 100%;
}

/* #endif */

/* #ifdef MP-ALIPAY */
page {
	min-height: 100vh;
}
/* #endif */

.margin-tb-xxs {
	margin-top: 5rpx;
	margin-bottom: 5rpx;
}

.uni-textarea-placeholder {
	color: #cccccc;
}

.my-bar .cu-avatar {
	background-color: transparent;
}

.cu-card.dynamic > .cu-item > .text-content {
	padding-top: 13rpx;
}

/*me 改colorUI*/
.cu-bar .action > text[class*='cuIcon-'],
.cu-bar .action > view[class*='cuIcon-'] {
	font-size: 46rpx;
}
.cu-bar .content {
	font-size: 38rpx;
}

/*me 新增*/
view.page {
	/* height: calc(100vh - 105rpx - env(safe-area-inset-bottom) / 2);      */
}
/*粘性定位  滑动到顶部固定*/
.sticky {
	position: -webkit-sticky;
	position: sticky;
	top: 0;
	z-index: 100;
}

.rotate360 {
	-webkit-transform: rotate(720deg);
	transform: rotate(720deg);
	-webkit-transform: scale(1.1, 1.1);
	transform: scale(1.1, 1.1);
	-webkit-transition: all 0.5s ease;
	transition: all 0.5s ease;
}
/* 图片载入替代方案 */
.image-wrapper {
	font-size: 0;
	background: #f3f3f3;
	border-radius: 4px;
	image {
		width: 100%;
		height: 100%;
		transition: 0.6s;
		opacity: 0;
		&.loaded {
			opacity: 1;
		}
	}
}
/*边框*/
.border-b:after,
.border-t:after {
	position: absolute;
	z-index: 3;
	left: 0;
	right: 0;
	height: 0;
	content: '';
	transform: scaleY(0.5);
	border-bottom: 1px solid $uni-border-color;
}

.border-b:after {
	bottom: 0;
}

.border-t:after {
	top: 0;
}
.height-100 {
	min-height: 100vh;
}
/* https://www.cnblogs.com/U-can/p/5545761.html */
.slideShine {
	text-align: center;
	background: -webkit-linear-gradient(left, #147b96, #e6d205 25%, #147b96 50%, #e6d205 75%, #147b96);
	color: transparent;
	-webkit-background-clip: text;
	background-size: 200% 100%;
	animation: masked-animation 1s infinite linear;
}
@-webkit-keyframes masked-animation {
	0% {
		background-position: 0 0;
	}
	100% {
		background-position: -100% 0;
	}
}
</style>
